<template>
  <div v-loading="loading">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px" class="dataForm">
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('出资人')" prop="lpId">
            <el-select v-model="form.lpId" filterable :disabled="!(selectLp || (parameter && Boolean(parseInt(parameter.selectLp))))" :placeholder="$t('出资人')" @change="getRaiseFundList(form.lpId)">
              <el-option
                v-for="item in lpBaseList"
                :key="item.id"
                :value="item.id"
                :label="item.name"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('事件发生类型')" prop="happenType">
            <!--            <el-input v-model="form.happenType" :placeholder="$t('事件发生类型')" show-word-limit maxlength="200" />-->
            <dict-select v-model="form.happenType" dictionary="lp_track_type" :placeholder="$t('事件发生类型')" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('发生时间')" prop="happenDate">
            <DatePicker
              v-model="form.happenDate"
              :placeholder="$t('发生时间')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('跟踪方式')" prop="trackMode">
            <dictSelect
              v-model="form.trackMode"
              :clearable="true"
              dictionary="track_mode"
              :is-check="true"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="form.lpId" :span="12">
          <el-form-item :label="$t('相关募集基金')" prop="investName" class="lp-class">
            <el-select v-model="form.fundId" :disabled="form.id" filterable :placeholder="$t('相关募集基金')" @change="setRaiseData">
              <el-option
                v-for="dict in raiseFundList"
                :key="dict.fundId"
                :label="$t(dict.fundName)"
                :value="dict.fundId"
              />
            </el-select>
            <el-button @click="addIntentionFund">{{ $t('添加意向基金') }}
            </el-button>
          </el-form-item>
        </el-col>
        <el-col v-if="form.lpId && form.fundId" :span="12">
          <el-form-item :label="$t('阶段')" prop="lpStage">
            <dictSelect
              v-model="form.lpStage"
              :disabled="form.id"
              :clearable="true"
              dictionary="lp_stage"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="form.lpId && form.fundId && form.lpStage && form.lpStage !== '14'" :span="12">
          <el-form-item :label="$t('预计签约时间')" prop="estimatedTime">
            <DatePicker
              v-model="form.estimatedTime"
              :disabled="form.id"
              :placeholder="$t('预计签约时间')"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="form.lpId && form.fundId && form.lpStage && form.lpStage !== '14'" :span="12">
          <el-form-item :label="$t('投资意向金额') + $t('金额单位')" prop="amountIntention">
            <Money v-model="form.amountIntention" :disabled="form.id" unit="w" :placeholder="$t('投资意向金额')" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col v-if="form.lpId && form.fundId && form.lpStage === '14'" :span="12">
          <el-form-item :label="$t('认缴时间')" prop="timeSubscription">
            <DatePicker
              v-model="form.timeSubscription"
              :disabled="form.lpType === 'now' || form.id"
              :placeholder="$t('认缴时间')"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="form.lpId && form.fundId && form.lpStage === '14'" :span="12">
          <el-form-item :label="$t('认缴金额') + $t('金额单位')" prop="subscribedAmount">
            <Money
              v-model="form.subscribedAmount"
              :disabled="form.lpType === 'now' || form.id"
              unit="w"
              oninput="value=value.replace(/[^\d.]/g,'')"
              :placeholder="$t('认缴金额')"
            >
              <template slot="append">
                <el-button v-if="form.lpType === 'now'" class="lineType" :disabled="form.id">{{ $t('新增认缴') }}
                  <el-switch
                    v-model="form.newAddSubscribedFlag"
                    :disabled="form.id"
                    active-color="#13ce66"
                    inactive-color="#c0c4cc"
                    active-value="Y"
                    inactive-value="N"
                    @click="newAddSubscribed(form.newAddSubscribedFlag)"
                  />
                </el-button>
              </template>
            </Money>
          </el-form-item>
        </el-col>
        <el-col v-if="form.lpId && form.fundId && form.lpStage === '14' && form.newAddSubscribedFlag === 'Y'" :span="12">
          <el-form-item :label="$t('新增认缴时间')" prop="newTimeSubscription">
            <el-date-picker
              v-model="form.newTimeSubscription"
              :disabled="form.id"
              clearable
              style="width: 200px"
              type="date"
              value-format="yyyy-MM-dd"
              :picker-options="pickerOptions"
              :placeholder="$t('新增认缴时间')"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="form.lpId && form.fundId && form.lpStage === '14' && form.newAddSubscribedFlag === 'Y'" :span="12">
          <el-form-item :label="$t('新增认缴金额') + $t('金额单位')" prop="newSubscribedAmount">
            <Money
              v-model="form.newSubscribedAmount"
              :disabled="form.id"
              unit="w"
              oninput="value=value.replace(/[^\d.]/g,'')"
              :placeholder="$t('新增认缴金额')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('对方人员')" prop="otherPeople">
            <el-input v-model="form.otherPeople" maxlength="100" show-word-limit :placeholder="$t('对方人员')" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('我方人员')" prop="ourPersonal">
            <el-input v-model="form.ourPerson" :placeholder="$t('我方人员')" show-word-limit maxlength="100" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('更新人')" prop="updateBy.nickName">
            <el-input v-model="form.updateBy.nickName" disabled show-word-limit maxlength="32" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('更新时间')" prop="updateTime">
            <el-input v-model="form.updateTime" disabled show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('详细情况')" prop="remark">
            <!--<el-input v-model="form.remark" type="textarea" :placeholder="$t('详细情况')" :autosize="{ minRows: 6 }" show-word-limit maxlength="2000" />-->
            <EditorTxt v-if="!loading" ref="editorTxt" v-model="form.remark" :height="300" :placeholder="$t('详细情况')" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('下一步计划')" prop="nextPlan">
            <!--<el-input v-model="form.nextPlan" type="textarea" :autosize="{ minRows: 6 }" maxlength="2000" show-word-limit :placeholder="$t('下一步计划')" />-->
            <EditorTxt v-if="!loading" v-model="form.nextPlan" :height="300" :placeholder="$t('下一步计划')" />
          </el-form-item>
        </el-col>
      </el-row>
      <!-- 只有安装了CRM才会显示，state 0是未安装 其他是已经安装 -->
      <div v-if="crmInstallState !== 0">
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('创建客户跟进任务')" prop="createTask">
              <el-radio-group v-model="form.createTask">
                <el-radio
                  v-for="dict in createTaskOptions"
                  :key="dict.dictValue"
                  :label="dict.dictValue"
                >{{ $t(dict.dictLabel) }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.createTask === 'Y'">
          <el-row>
            <el-col :span="12">
              <el-form-item :label="$t('任务名称')" prop="taskName">
                <el-input v-model="form.taskName" :placeholder="$t('任务名称')" show-word-limit maxlength="100" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('关联基金')" prop="fundId">
                <el-select v-model="form.fundId" filterable disabled placeholder="关联基金">
                  <el-option
                    v-for="dict in raiseFundList"
                    :key="dict.fundId"
                    :label="$t(dict.fundName)"
                    :value="dict.fundId"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('跟进时间')" prop="followTime">
                <el-date-picker
                  v-model="form.followTime"
                  type="date"
                  placeholder="跟进时间"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('跟进人员')" prop="followUser">
                <UserSelect v-model="form.followUser" :placeholder="$t('跟进人员')" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('对接联系人')" prop="connectContact" class="lp-class">
                <el-select v-model="form.connectContact" clearable multiple filterable :placeholder="$t('对接联系人')">
                  <el-option
                    v-for="item in contactPeopleOptions"
                    :key="item.id"
                    :label="item.contactsName"
                    :value="item.id"
                  />
                </el-select>
                <el-button @click="addContactPerson">{{ $t('添加联系人') }}</el-button>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('跟进方式')" prop="followType">
                <el-select v-model="form.followType" :placeholder="$t('跟进方式')" clearable>
                  <el-option
                    v-for="dict in followTypeOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictValue"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('提醒状态')" prop="status">
                <el-switch
                  v-model="form.status"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  :active-text="$t('开启')"
                  :inactive-text="$t('关闭')"
                  :active-value="1"
                  :inactive-value="0"
                />
              </el-form-item>
            </el-col>
            <!--            <el-col v-if="form.status === 1" :span="12">-->
            <!--              <el-form-item :label="$t('是否同步提醒对接联系人')" prop="whetherRemindContact">-->
            <!--                <el-radio-group v-model="form.whetherRemindContact">-->
            <!--                  <el-radio-->
            <!--                    v-for="dict in sysYesNoOptions"-->
            <!--                    :key="dict.dictValue"-->
            <!--                    :label="dict.dictValue"-->
            <!--                  >{{ $t(dict.dictLabel) }}-->
            <!--                  </el-radio>-->
            <!--                </el-radio-group>-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <el-col v-if="form.status === 1" :span="12">
              <el-form-item :label="$t('提醒用户')" prop="remindUser">
                <UserSelect v-model="form.remindUser" :multiple="true" :placeholder="$t('提醒用户')" />
              </el-form-item>
            </el-col>
            <el-col v-if="form.status === 1" :span="12">
              <el-form-item :label="$t('提醒频率')" prop="reminderFrequency">
                <el-radio-group v-model="form.reminderFrequency">
                  <el-radio
                    v-for="dict in reminderFrequencyOptions"
                    :key="dict.dictValue"
                    :label="dict.dictValue"
                  >{{ $t(dict.dictLabel) }}
                  </el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-if="form.status === 1">
            <el-col v-if="form.reminderFrequency === 'TIMER'" :span="12">
              <el-form-item :label="$t('定时提醒时间')" prop="remindTime">
                <el-date-picker
                  v-model="form.remindTime"
                  clearable
                  style="width: 200px"
                  type="datetime"
                  :placeholder="$t('定时提醒时间')"
                />
              </el-form-item>
            </el-col>
            <el-col v-else :span="24">
              <el-form-item :label="$t('频率提醒表达式')" prop="cron">
                <Cron v-model="form.cron" :cron-value.sync="form.frequencyCronValue" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <!--          <el-col :span="12">-->
            <!--            <el-form-item :label="$t('排序')" prop="sort">-->
            <!--              <el-input-number v-model="form.sort" controls-position="right" :placeholder="$t('排序')" :precision="0" :max="10000000" />-->
            <!--            </el-form-item>-->
            <!--          </el-col>-->
            <el-col :span="24">
              <el-form-item :label="$t('跟进内容')" prop="followContent">
                <el-input v-model="form.followContent" type="textarea" :placeholder="$t('跟进内容')" show-word-limit maxlength="1000" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-row>
      </div>
      <FileTable :list.sync="form.fileList" data-type="lp_track" :business-id="this.$route.query.lpId" />
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align: right;">
      <!--保存，保存并启动流程，取消 三个按钮-->
      <save-btn has-permi="fund:lpTrack" />
    </div>
    <!-- 添加或修改意向投资人对话框 -->
    <el-dialog :title="title" :visible.sync="intentionOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm" append-to-body>
      <addFundIntentionInvestForm ref="addFundIntentionInvestForm" @sendIntentionInvestData="sendIntentionInvestData" />
    </el-dialog>
    <!-- 添加或修改项目联系人对话框 -->
    <el-dialog :title="$t('添加联系人')" :visible.sync="contactOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm m0" append-to-body>
      <contactPersonForm ref="contactPersonForm" :bus-type="'lpInvestor'" @sendContactPersonData="sendContactPersonData" />
    </el-dialog>
  </div>
</template>

<script>
    import { saveLpTrack, getLpTrack } from '@/api/fund/lpTrack/lpTrack'
    import { getUserProfile } from '@/api/system/user'
    import { getAllIdAndName } from '@/api/fund/lpBase/lpBase'
    import { getRaiseFundList } from '@/api/fund/investor/fundInvestor'
    import addFundIntentionInvestForm from '@/views/fund/intentionInvest/addFundIntentionInvestForm.vue'
    import { listDealContacts } from '@/api/deal/contact/contactsPerson'
    import { getAppList } from '@/api/market'
    import ContactPersonForm from '@/views/deal/contact/contactPersonForm.vue'
    import EditorTxt from '@/components/Tinymce'

    export default {
      components: {
        EditorTxt,
        ContactPersonForm,
        addFundIntentionInvestForm
      },
      props: {
        lpId: {
          type: String,
          default: undefined
        },
        selectLp: {
          type: Boolean,
          default: false
        },
        parameter: {
          type: Object,
          default: null
        }
      },
        data() {
            return {
                // CRMtodo创建任务
                createTaskOptions: [],
                // 系统是否
                sysYesNoOptions: [],
                // 跟进方式
                followTypeOptions: [],
                // 对应客户的联系人
                contactPeopleOptions: [],
                reminderFrequencyOptions: [],
                // 联系人窗口开关
                contactOpen: false,
                // 是否安装募集CRM state 0是未安装 其他是已经安装
                crmInstallState: 0,
                // 表单参数
                form: {
                  updateBy: {
                    nickName: undefined
                  },
                  fileList: []
                },
                // 募集基金列表
                raiseFundList: [],
                intentionOpen: false,
                title: '添加意向出资人',
                // 遮罩层
                loading: false,
                // 表单校验
                rules: {
                  happenType: [{ required: true, message: this.$t('必填信息'), trigger: 'change' }],
                  happenDate: [{ required: true, message: this.$t('必填信息'), trigger: 'change' }],
                  trackMode: [{ required: true, message: this.$t('必填信息'), trigger: 'change' }],
                  remark: [{ required: true, message: this.$t('必填信息'), trigger: 'change' }],
                  lpId: [{ required: true, message: this.$t('必填信息'), trigger: 'change' }],
                  taskName: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  followTime: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  followUser: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  connectCustomer: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  connectContact: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  timeSubscription: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  subscribedAmount: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  newTimeSubscription: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  newSubscribedAmount: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  signTime: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  followType: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  createTask: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
                  followContent: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }]
                },
              lpBaseList: []
            }
        },
        // watch: {
        //   'form.whetherRemindContact': {
        //     handler(val) {
        //       if (val === 'Y') {
        //         this.rules.connectContact = [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }]
        //       } else {
        //         this.rules.connectContact = [{ required: false, message: this.$t('必填信息'), trigger: 'blur' }]
        //       }
        //     },
        //     deep: true,
        //     immediate: true
        //   }
        // },
        computed: {
          pickerOptions() {
            var _this = this
            return {
              disabledDate(time) {
                var date = Date.now()
                if (_this.form.timeSubscription !== null && _this.form.timeSubscription !== undefined && _this.form.timeSubscription !== '') {
                  date = new Date(_this.form.timeSubscription).getTime()
                }
                return time.getTime() < date
              }
            }
          }
        },
        created() {
          if (this.$route.query.lpId) {
            this.getRaiseFundList(this.$route.query.lpId)
          }
          this.getDicts('create_task').then(response => {
            this.createTaskOptions = response.data
          })
          this.getDicts('sys_yes_no').then(response => {
            this.sysYesNoOptions = response.data
          })
          this.getDicts('reminder_frequency').then(response => {
            this.reminderFrequencyOptions = response.data
          })
          this.getDicts('follow_method').then(response => {
            this.followTypeOptions = response.data
          })
          getAppList({ appName: '募资CRM' }).then(response => {
            console.log('判断CRM是否开启', response)
            this.crmInstallState = response.rows[0].state
          })
          getAllIdAndName().then(res => {
            this.lpBaseList = res.data
          })
        },
      mounted() {
        this.$bus.$emit('async_done')
      },
      methods: {
            // 初始化数据
            init(data) {
                this.reset()
                this.loading = true
                if (data != null && data.id !== undefined) {
                    getLpTrack(data.id).then(response => {
                        this.form = response.data
                        getRaiseFundList(this.form.lpId).then(response => {
                          this.raiseFundList = response.data
                        })
                        listDealContacts({ businessId: this.form.lpId }).then(response => {
                          this.contactPeopleOptions = response.rows
                        })
                        this.loading = false
                    })
                } else {
                    this.reset()
                  if (data) {
                    this.form.lpId = data.lpId
                  }
                    getUserProfile().then(response => {
                      this.form.updateBy = response.data
                      this.loading = false
                    })
                }
            },
            // 根据客户ID获取募集基金集合
            getRaiseFundList(lpId) {
              this.form.fundId = undefined
              getRaiseFundList(lpId).then(response => {
                this.raiseFundList = response.data
              })
              if (lpId !== null && lpId !== undefined && lpId !== '') {
                const param = {
                  businessId: lpId
                }
                listDealContacts(param).then(response => {
                  this.contactPeopleOptions = response.rows
                })
              }
            },
            // 根据选择的募集基金设置对应的数据
            setRaiseData(fundId) {
              console.log('fundId', fundId)
              this.raiseFundList.forEach(item => {
                if (item.fundId === fundId) {
                  // 阶段
                  this.form.lpStage = item.lpStage
                  this.form.investorId = item.investorId
                  // 当前类型lpType（出资人：now、意向出资人：intention）
                  this.form.lpType = item.lpType
                  if (item.lpType === 'now') {
                    // 阶段 出资人默认签署阶段
                    this.form.lpStage = '14'
                    this.$nextTick(() => {
                      // 认缴时间
                      this.form.timeSubscription = item.timeSubscription
                      // 认缴金额
                      this.form.subscribedAmount = item.subscribedAmount
                      // 预计签约时间 investmentTime
                      this.form.estimatedTime = undefined
                      // 投资意向金额 subscribedAmount
                      this.form.amountIntention = undefined
                    })
                  } else {
                    if (item.lpStage) {
                      this.form.lpStage = item.lpStage
                    } else {
                      this.form.lpStage = '1'
                    }
                    this.$nextTick(() => {
                      // 预计签约时间 investmentTime
                      this.form.estimatedTime = item.timeSubscription
                      // 投资意向金额 subscribedAmount
                      this.form.amountIntention = item.subscribedAmount
                      // 认缴时间
                      this.form.timeSubscription = undefined
                      // 认缴金额
                      this.form.subscribedAmount = undefined
                    })
                  }
                }
              })
            },
          // 添加意向基金
          addIntentionFund() {
            this.intentionOpen = true
            this.title = this.$t('添加意向基金')
            var data = {
              type: undefined,
              lpId: this.form.lpId
            }
            this.lpBaseList.forEach(item => {
              if (item.id === this.form.lpId) {
                data.type = item.type
              }
            })
            this.$nextTick(() => {
              this.$refs.addFundIntentionInvestForm.init(data)
            })
          },
          sendIntentionInvestData(data) {
              console.log('添加成功意向出资人返回的数据', data)
              const row = {
                fundId: data.fundId,
                fundName: data.fundName,
                lpStage: undefined,
                estimatedTime: data.estimatedTime,
                amountIntention: data.amountIntention,
                investmentTime: undefined,
                subscribedAmount: undefined,
                lpType: 'intention'
              }
              if (data.lpStage) {
                row.lpStage = data.lpStage
              } else {
                row.lpStage = '1'
              }
              this.raiseFundList.push(row)
          },
          /** 添加联系人 */
          addContactPerson() {
            this.contactOpen = true
            this.$nextTick(() => {
              const data = {
                lpId: this.form.lpId
              }
              // 调用form页面的 init 方法初始化数据
              this.$refs.contactPersonForm.init(data)
            })
          },
          // 保存联系人成功后，把联系人添加对接联系人选项
          sendContactPersonData(data) {
            const item = {
              id: data.id,
              contactsName: data.contactsName,
              personType: data.personType,
              businessType: data.businessType,
              businessId: data.businessId
            }
            this.contactPeopleOptions.push(item)
          },
            // 表单重置
            reset() {
                this.form = {
                id: undefined,
                lpId: this.$route.query.lpId || this.lpId,
                happenType: undefined,
                happenDate: undefined,
                trackMode: undefined,
                fundId: undefined,
                investorId: undefined,
                lpStage: undefined,
                lpType: undefined,
                estimatedTime: undefined,
                amountIntention: undefined,
                timeSubscription: undefined,
                subscribedAmount: undefined,
                newTimeSubscription: undefined,
                newSubscribedAmount: undefined,
                newAddSubscribedFlag: 'N',
                otherPeople: undefined,
                nextPlan: undefined,
                createBy: undefined,
                createTime: undefined,
                updateBy: {},
                updateTime: undefined,
                delFlag: undefined,
                remark: undefined,
                ourPerson: undefined,
                fileList: [],
                // to do下一步计划相关字段
                followTime: new Date(), // 跟进时间
                followUser: this.$store.state.user.userId, // 跟进人员
                connectContact: [], // 对接联系人
                followType: undefined, // 跟进方式
                remindTime: undefined, // 定时提醒时间
                remindUser: undefined, // 提醒用户
                frequencyCronValue: undefined, // 频率提醒表达式
                whetherRemindContact: 'N', // 是否同步提醒对接联系人
                cron: undefined, // 定时器表达式
                reminderFrequency: 'TIMER', // 提醒频率
                status: 1, // 提醒状态
                createTask: 'N', // 创建客户跟进任务
                followContent: undefined, // 跟进内容
                taskName: undefined // 任务名称
                }
                this.resetForm('form')
            },
            // 取消按钮
            cancel() {
                this.$parent.$parent.formOpen = false
                this.$parent.$parent.reset()
            },
            // 关闭form页面
            closeForm() {
                // 关闭form页面遮罩层
                this.loading = false
                // 关闭form页面
                this.$parent.$parent.formOpen = false
                // 刷新list页面
                this.$parent.$parent.getList()
                this.$parent.$parent.$parent.$parent.getList()
            },
            /** 提交按钮 */
            submitForm: function() {
                this.$refs['form'].validate(valid => {
                    if (valid) {
                        this.loading = true
                        // // 这里处理从意向出资人->出资人的过程，把lpType设置成'now'，由于页面需要判断，没有修改lpType类型，所以保存这里处理
                        // var lpStage = this.form.lpStage
                        // if (lpStage !== null && lpStage !== undefined && lpStage !== '' && lpStage === '14') {
                        //   this.form.lpType = 'now'
                        // }
                        saveLpTrack(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess(this.$t('保存成功'))
                                this.closeForm()
                            } else {
                                this.msgError(response.msg)
                            }
                            this.loading = false
                        })
                    } else {
                      this.locationError(document)
                    }
                })
           },
          // 新增认缴按钮操作
          newAddSubscribed(val) {
              if (val === 'Y') {
                this.form.newAddSubscribedFlag = 'N'
              } else {
                this.form.newAddSubscribedFlag = 'Y'
              }
          }
        }

    }
</script>
<style lang="scss" scoped>
::v-deep .lineType{
  span {
    display: flex;
    align-items: center;
  }
}
</style>
